﻿using UnityEngine;
using System.Collections;


public class SelectMode : MonoBehaviour {
    public Texture2D ArrowTexture;
    public Texture2D ArrowHoverTexture;
    public Texture2D ArrowSelectTexture;
    public Texture2D MouseTexture;
    public Texture2D MouseHoverTexture;
    public Texture2D MouseSelectTexture;

    /// <summary>
    /// Called at the creation of the game.
    /// </summary>
    void Start()
    {
        GameObject.Find("Arrows").guiTexture.texture = ArrowSelectTexture;
        PlayerPrefs.SetInt("option", 1);
    }

    /// <summary>
    /// Called when [mouse up].
    /// </summary>
	void OnMouseUp(){
        // change the selected option with a click

		if (gameObject.name == "Arrows") {
            gameObject.guiTexture.texture = ArrowSelectTexture;
            GameObject.Find("Mouse").guiTexture.texture = MouseTexture;
			PlayerPrefs.SetInt("option",1);
		}
		else if(gameObject.name == "Mouse"){
            gameObject.guiTexture.texture = MouseSelectTexture;
            GameObject.Find("Arrows").guiTexture.texture = ArrowTexture;
			PlayerPrefs.SetInt("option",2);
		}            
	}

    /// <summary>
    /// Called when [mouse enter].
    /// </summary>
    void OnMouseEnter()
    {
        if (gameObject.name == "Arrows")
        {
            if (gameObject.guiTexture.texture != ArrowSelectTexture)
            {
                gameObject.guiTexture.texture = ArrowHoverTexture;
            }  
        }
        else if (gameObject.name == "Mouse")
        {
            if (gameObject.guiTexture.texture != MouseSelectTexture)
            {
                gameObject.guiTexture.texture = MouseHoverTexture;
            }   
        }
    }

    /// <summary>
    /// Called when [mouse exit].
    /// </summary>
    void OnMouseExit()
    {
        if (gameObject.name == "Arrows")
        {
            if (gameObject.guiTexture.texture != ArrowSelectTexture)
            {
                gameObject.guiTexture.texture = ArrowTexture;
            }            
        }
        else if (gameObject.name == "Mouse")
        {
            if (gameObject.guiTexture.texture != MouseSelectTexture)
            {
                gameObject.guiTexture.texture = MouseTexture;
            }            
        }
    }
}
